#pragma once
#ifndef LOGIC_MANAGER_H
#define LOGIC_MANAGER_H
#include <map>
  
#include "ProtoDispatch.h"
#include "google/protobuf/message.h"
#include "LogicProtoBase.h"

class LogicClientManager : public LogicProtoBase
{
private:
    static LogicClientManager * pclassobj;

    LogicClientManager() {fd = 0;}
  
public:
    static LogicClientManager * GetInstance();

    //注册事件处理
    virtual int RegProto();
  
    //调用回调函数
    virtual int OnMessage(Message * msg, void *);

    void SetFd(unsigned fd) {this->fd = fd;}

    int BeginLogin();

    int SendMessage(Message * msg);

private:
    Distpater _dispatch;
    unsigned fd;
};
  
class ProtoClientManager
{
private:
    ProtoClientManager() {}
public:
    template<class T, class T2>
    static int ProcessProto(T *msg, void *)
    {
        //客户端收到信息后，不需要发送响应给服务端
        int ret = T2::GetInstance()->Process(msg);
 
        return ret;
    }
};
  
#endif  //LOGIC_MANAGER_H

